<?php
namespace Home\Controller;
use Think\Controller;
class FriendsController extends Controller {
	//关注的人数，粉丝人数
		public function friends(){			
			$this->display();			
		}	
	//添加关注	
		public function doGz(){
			$tid=$_GET['tid'];
			$gz=M('Friends');
			$fid=$_SESSION['uid'];
			$cid=$_GET['cid'];
			$data=array(
				'fid'=>$fid,
				'cid'=>$cid,
				'fensi'=>1,
			);
			$gz->add($data);
			$this->success('关注成功');
			$this->redirect('Message/remen',array('tid' => $tid));
		}
	//取消关注
		public function doCancelGz(){
			$gz=M('Friends');
			$where['cid']=$cid=$_GET['cid'];
			$where['fid']=$fid=$_SESSION['uid'];
			$where['fensi']=1;
			$gz->where($where)->delete();
			$this->success('取消关注成功');
			
		}
	//添加好友
		public function doAdd(){
			$tid=$_GET['tid'];
			$add=M('Friends');
			$fid=$_SESSION['uid'];
			$cid=$_GET['cid'];
			$data=array(
				'fid'=>$fid,
				'cid'=>$cid,
				'fensi'=>0,
				'state'=>0,
			);
			$add->add($data);
			$this->success('已发送好友请求，等待对方验证');
			$this->redirect('Message/remen',array('tid' => $tid));
		}
	
	
	//可以简化代码，利用一个判断语句。	
}
?>